home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / net / plip_3812src.lha / plip / src / int.asm < prev    next >
Assembly Source File  |  1994-03-02  |  2KB  |  166 lines

  1. *
  2. * interrupt-driver
  3. *
  4.  
  5.  
  6.     section    "text"
  7.  
  8.     xdef    _settimeout
  9. TIMEOUT    dc.l    $4fffff
  10. _settimeout:
  11.     lea    TIMEOUT(pc),a0    ; 4 bytes
  12.     move.l    d0,(a0)        ; 2 bytes
  13.     rts
  14.  
  15.     xdef    _parinit
  16.     xdef    _testbusy
  17.     xdef    _setbusy
  18.     xdef    _waitinputtoggle
  19.     xdef    _outputtoggle
  20.     xdef    _setciaoutput
  21.     xdef    _sampleinput
  22.     xdef    _testpout
  23.     xdef    _setpout
  24.     xdef    @intcode
  25.  
  26. currentinput:    dc.w    0
  27. iamclient:    dc.w    0    
  28.  
  29. _sampleinput:    
  30.     lea    currentinput(pc),a0
  31.     moveq    #0,d0
  32.     move.w    2(a0),d0    ; iamclient
  33.     bchg    #0,d0
  34.     btst.b    d0,$bfd000
  35.     sne.b    (a0)        ; currentinput
  36.     rts
  37.  
  38. _waitinputtoggle:
  39.     lea    currentinput(pc),a0
  40.     lea    $bfd000,a1    ; ciaa
  41.     move.l    TIMEOUT(pc),d1
  42.     moveq    #0,d0
  43.     move.w    2(a0),d0    ; iamclient
  44.     bchg    #0,d0
  45.     tst.b    (a0)
  46.     beq.s    inputnotset
  47. itl1:
  48.     btst.b    d0,(a1)
  49.     beq.s    exa1
  50.     subq.l    #1,d1
  51.     bpl.s    itl1
  52. exa1:
  53.     addq.l    #1,d1
  54.     move.l    d1,d0
  55.     beq.s    rettt
  56.     clr.b    (a0)    ; currentinput
  57.     rts
  58.  
  59. inputnotset:
  60.     btst.b    d0,(a1)
  61.     bne.s    exa2
  62.     subq.l    #1,d1
  63.     bpl.s    inputnotset
  64. exa2:
  65.     addq.l    #1,d1
  66.     move.l    d1,d0
  67.     beq.s    rettt
  68.     move.b    #42,(a0)    ; currentinput
  69. rettt:
  70.     rts
  71.  
  72. _outputtoggle:
  73.     moveq    #0,d0
  74.     move.w    iamclient(pc),d0
  75.     bchg.b    d0,$bfd000
  76.     rts
  77.  
  78. _setciaoutput:
  79.     move.b    #$ff,$bfe301    ; data out
  80.     rts
  81.  
  82. _testbusy:
  83.     moveq    #0,d0
  84.     btst.b    #0,$bfd000
  85.     sne    d0
  86.     rts
  87.  
  88. _testpout:
  89.     moveq    #0,d0
  90.     btst.b    #1,$bfd000
  91.     sne    d0
  92.     rts
  93.  
  94. _setbusy:
  95.     tst.l    d0
  96.     bne.s    sb1
  97.     bclr.b    #0,$bfd000
  98.     rts
  99. sb1:
  100.     bset.b    #0,$bfd000
  101.     rts
  102.  
  103. _setpout:
  104.     tst.l    d0
  105.     bne.s    sp1
  106.     bclr.b    #1,$bfd000
  107.     rts
  108. sp1:
  109.     bset.b    #1,$bfd000
  110.     rts
  111.  
  112.  
  113. ; Init parallel port
  114. ; d0==1 = client-mode
  115. _parinit:
  116.     lea    $bfd000,a0
  117. ;    move.b    #0,$bfe301    ; all parallel bits input
  118.     move.b    #0,$bfe301-$bfd000(a0)
  119.     move.w    d0,iamclient    ; client?
  120.     beq.s    servermode
  121.     bset.b    #1,$200(a0)    ; pout output
  122.     bclr.b    #0,$200(a0)    ; busy input
  123.     bclr.b    #1,(a0)    ; POUT low
  124.     rts
  125. servermode:
  126.     bclr.b    #1,$200(a0)    ; pout input
  127.     bset.b    #0,$200(a0)    ; busy output
  128.     bset.b    #0,(a0)        ; BUSY high (send enable)
  129. consetup:
  130.     rts
  131.  
  132. ; Der eigentliche Interrupt-Server
  133. ; a1 = data
  134. @intcode:
  135.     move.w    (a1),d0    ; mode-word
  136.     btst    #1,d0    ; sende?
  137.     beq.s    recmode
  138. return:
  139.     rts
  140.  
  141. ; Empfangs-Modus: a1 = data, d0 = modes
  142. recmode:
  143.     btst    #2,d0        ; schon recmode?
  144.     bne.s    return
  145.  
  146. ; Prüfen, ob Arbitration richtig
  147.     btst    #0,d0
  148.     bne.s    clientrec
  149.     btst.b    #1,$bfd000    ; POUT high?
  150.     bne.s    recmodeok    ; wenn nein, dann belegt
  151.     rts
  152. clientrec:
  153.     btst.b    #0,$bfd000    ; busy low?
  154.     bne.s    return
  155. recmodeok:
  156.     or.w    #4,(a1)    ; RECEIVE setzen
  157.  
  158. ; load params
  159.     movem.l    4(a1),d0/a1/a6
  160. ;    move.l    4(a1),d0
  161. ;    move.l    8(a1),a1
  162. ;    move.l    4,a6
  163.     jmp    -324(a6)    ; Signal (Empfangsbeginn)
  164.     
  165.     END
  166.